import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

import 'antd/dist/antd.less'
import zhCN from 'antd/lib/locale/zh_CN'
import { ConfigProvider } from 'antd'

import { whiteList } from './routes'
import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect,
} from 'react-router-dom'

import { Provider } from 'react-redux'
import store from './store'

import './utils/permission'

ReactDOM.render(
  <Provider store={store}>
    <Router>
      <ConfigProvider locale={zhCN}>
        <Switch>
          {whiteList.map((route) => (
            <Route
              key={route.path}
              path={route.path}
              component={route.component}
            />
          ))}

          <Route path="/admin" component={App} />

          <Redirect to="/admin" from="/" exact />
          <Redirect to="/404" />
        </Switch>
      </ConfigProvider>
    </Router>
  </Provider>,
  document.getElementById('root')
)
